﻿using System.Collections;
using System.Collections.Generic;
using NpcFramework;
using UnityEngine;
using Yoozoo.Mars.Got;

namespace Yoozoo.Core.Common
{
    public class PveQualityListener : 
        QualityListenerMono<PveQualityListener.PveQualitySetting>,
        ILightShadowLevelAdjuster,
        IPveSceneQualityAdjuster
    {
        [System.Serializable]
        public class PveQualitySetting : QualitySetting
        {
            // 阴影
            [Range(0,4)]
            public int maxShadowLOD = 1;
            [Range(0,200)]
            public int disableShadowDistance = 25;
            
            [Range(0,10)]
            public int maxTrafficWaitCount = 4;
            
            // 视野检测框
            public Vector3 detectorSize = new Vector3(50, 50, 50);
            public float detectorForwardOffset = 20f;
            public Vector3 detectorPosOffset = Vector3.zero;

            public void Apply()
            {
                NFConstValue.MAX_TRAFFIC_WAIT_COUNT = maxTrafficWaitCount;
                NFConstValue.onQualityChange?.Invoke();
            }

            public void ApplyShadowQuality()
            {
                NFConstValue.MAXShadowLOD = maxShadowLOD;
                NFConstValue.DisableShadowDistance = disableShadowDistance;
            }
        }


        protected override void Awake()
        {
            base.Awake();
            NFConstValue nfConstValue = new NFConstValue();
        }

        public override void ChangeQualitySetting(PveQualitySetting qualitySetting)
        {
            qualitySetting.Apply();
        }

        public void ChangeLightLevel(QualityEnum quality)
        {
            
        }

        public void ChangeShadowLevel(QualityEnum quality)
        {
            PveQualitySetting qualitySetting = GetQualitySetting(quality);
            if (qualitySetting!=null)
            {
                qualitySetting.ApplyShadowQuality();
            }
        }

        public void ChangeNpcCount(int npcCount, int carCount)
        {
            NFConstValue.MaxNpcNum = npcCount;
            NFConstValue.RandomNpcMaxNum = npcCount;
            NFConstValue.MaxCarNum = carCount;
        }
    }
}
